package com.eight.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eight.mapper.OperateLogMapper;
import com.eight.pojo.SysOperLog;
import com.eight.service.OperateLogService;
import com.eight.vo.ComResult;
import com.eight.vo.OperateLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: TODO
 * @Author: Van.Planifolia
 * @CreateTime: 2023-03-01  14:52
 * @Version: 1.0
 */
@Service("operateLogService")
public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, SysOperLog> implements OperateLogService {
    @Autowired
    private OperateLogMapper operateLogMapper;


    /**
     * 分页条件查询所有数据
     *
     * @param operateLogVo 查询条件
     * @param pageIndex    当前页
     * @param pageSize     页中数据条数
     * @return 相应前端
     */
    @Override
    public ComResult selectAllOperatelog(OperateLogVo operateLogVo, Integer pageIndex, Integer pageSize) {
        Page<SysOperLog> page = new Page<>(pageIndex, pageSize);
        page = operateLogMapper.selectAllOperatelog(page, operateLogVo);
        if (page != null) {
            return new ComResult(2000, "查询成功", page);
        } else {
            return new ComResult(2000, "查询失败");
        }
    }

    /**
     * 根据年份来分类不同操作的占比信息
     *
     * @param year 年份信息
     * @return 查询的结果
     */
    @Override
    public ComResult selectOperateLogByName(String year) {
        return new ComResult(2000, "查询成功", operateLogMapper.selectOperateLogByName(year));
    }

    /**
     * 根据年份来分类不同ip的占比信息
     *
     * @param year 年份
     * @return 结果
     */
    @Override
    public ComResult selectOperateLogByAddress(String year) {
        return new ComResult(2000, "查询成功", operateLogMapper.selectOperateLogByAddress(year));
    }
}
